﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SERP.StringMappings;
using SERP.DAO;
using SERP.Controllers;
namespace SERP.Modules.Users{
	public partial class UsersViewInfo : SERP.Modules.ModuleBase
	{
		private UsersController controller = new UsersController();
		public UsersController Controller{
			get{
				return controller;
			} 
		}
		protected void Page_Load(object sender, EventArgs e){
    		LoadLanguage();	
			if(!this.IsPostBack){		
				BindInfo();	
			}
		}
		//Load All lable text
		private void LoadLanguage(){
			labelUserName.Text=UsersStringMapping.UserName+":";
			labelPassword.Text=UsersStringMapping.Password+":";
			labelDisplayName.Text=UsersStringMapping.DisplayName+":";
			labelBirthDay.Text=UsersStringMapping.BirthDay+":";
			labelEmail.Text=UsersStringMapping.Email+":";
			labelGender.Text=UsersStringMapping.Gender+":";
			labelAddress.Text=UsersStringMapping.Address+":";
			labelPhone.Text=UsersStringMapping.Phone+":";
			labelIsActived.Text=UsersStringMapping.IsActived+":";
			labelUserType.Text=UsersStringMapping.UserType+":";
		}
		public UsersEntity GetObject(){
			controller.LoadObject(Int32.Parse(Request["UserId"]));
			return controller.UsersObject;
		}
		private void BindInfo(){
			UsersEntity o=GetObject();		
			CopyToSreen(o);
		}
		private void CopyToSreen(UsersEntity o){
			txtUserName.Text=o.UserName;
			txtPassword.Text=o.Password;
			txtDisplayName.Text=o.DisplayName;
			txtBirthDay.Text=o.BirthDay.ToString(SERP.Constants.APP_DATE_FORMAT);
			txtEmail.Text=o.Email;
			txtGender.Text=Convert.ToString(o.Gender);
			txtAddress.Text=o.Address;
			txtPhone.Text=o.Phone;
			txtIsActived.Text=o.IsActived==null?SERP.Constants.APP_TRUE:(o.IsActived?SERP.Constants.APP_TRUE:SERP.Constants.APP_FALSE);
			txtUserType.Text=Convert.ToString(o.UserType);
		}   
}
}
